package com.sundi.ecusers.web;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.sundi.eccommon.vo.ResultEntity;
import com.sundi.ecusers.dto.EcAddressDto;
import com.sundi.ecusers.entity.EcAddress;
import com.sundi.ecusers.service.IEcAddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 收货地址表 前端控制器
 * </p>
 *
 * @author Mht
 * @since 2020-02-26
 */
@RestController
@RequestMapping("/ecAddress")
public class EcAddressController {

    @Autowired
    IEcAddressService iEcAddressService;

    /**
     * 收货地址列表，模糊查询
     * @param user_id
     * @param name
     * @param ecAddressDto
     * @return
     */
    @RequestMapping("getAddressList")
    public ResultEntity getAddressList(Integer user_id, String name, EcAddressDto ecAddressDto){

        PageHelper.startPage(ecAddressDto.getPageNo(),ecAddressDto.getPageSize());
        List<EcAddress> addressList = iEcAddressService.getAddressList(user_id,name);
        PageInfo<EcAddress> pageInfo = new PageInfo<EcAddress>(addressList);
        return ResultEntity.ok(pageInfo);
    }
}
